//
// Created by heqian on 17-8-2.
//

#ifndef AUTOMAHJONG_IMAGE_H
#define AUTOMAHJONG_IMAGE_H

#include <stdint.h>
#include <string.h>
#include "../utils/Prt.h"

namespace img {
    /**
     * 图像格式
     */
    enum ImageFormat {
        IMAGE_FORMAT_NONE = 0,
        IMAGE_FORMAT_RGBA_8888 = 1,
        IMAGE_FORMAT_RGB_565 = 4,
        IMAGE_FORMAT_RGBA_4444 = 7,
        IMAGE_FORMAT_A_8 = 8,
    };

    /**
    * 通道
    */
    enum ImageChannel {
        CHANNEL_NONE = 0,
        CHANNEL_ALPHA = 1,//透明
        CHANNEL_BLUE = 2, //蓝
        CHANNEL_GREEN = 3, //绿
        CHANNEL_RED = 4 //红
    };

    class Image {
    public:
        Image();

        Image(uint32_t width, uint32_t height, ImageFormat format);

        Image(uint32_t width, uint32_t height, void *pData, ImageFormat format);

        uint32_t getWidth() const;

        void setWidth(uint32_t mWidth);

        uint32_t getHeight() const;

        void setHeight(uint32_t mHeight);

        uint32_t getStride() const;

        void setStride(uint32_t mStride);

        ImageFormat getFormat() const;

        void setFormat(ImageFormat format);

        uint32_t getFlags() const;

        void setFlags(uint32_t mFlags);

        void *getData() const;

        void setpData(void *mpData);

        virtual ~Image();


    protected:
        uint32_t mWidth;
        uint32_t mHeight;
        uint32_t mStride;
        ImageFormat mFormat;
        uint32_t mFlags;      // 0 for now
        void *mpData;

        bool mFreeData;

        void create(uint32_t width, uint32_t height, ImageFormat format);
    };

}
#endif //AUTOMAHJONG_IMAGE_H
